﻿<UserControl x:Class="TFSCodeReviewHelper.AssetGrid"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:controls="clr-namespace:TFSCodeReviewHelper"
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="800">
    <Control.Resources>
        <DataTemplate x:Key="AssetLocation" DataType="Profile">
            <TextBox IsReadOnly="True" MouseDoubleClick="AssetLocationTextBox_MouseDoubleClick" MinWidth="100" HorizontalAlignment="Stretch" BorderThickness="0" Background="Transparent">
                <TextBox.Text>
                    <Binding Path="Location"/>
                </TextBox.Text>
            </TextBox>
        </DataTemplate>
        <DataTemplate x:Key="PreviousChangesetEntry" DataType="Profile">
            <TextBlock Width="60" HorizontalAlignment="Center" TextAlignment="Center" Text="{Binding Path='PreviousChangeset'}"/>
        </DataTemplate>
        <DataTemplate x:Key="LastChangesetEntry" DataType="Profile">
            <TextBlock Width="60" HorizontalAlignment="Center" TextAlignment="Center" Text="{Binding Path='LastChangeset'}"/>
        </DataTemplate>
        <DataTemplate x:Key="ParticipationEntry1" DataType="Profile">
            <ContentControl>
                <Binding Path="ChangesetParticiationControl"/>
            </ContentControl>
        </DataTemplate>
        <DataTemplate x:Key="ParticipationEntry" DataType="Profile">
            <controls:ChangesetParticiationControl ChangeSelected="ChangesetParticiationControl_ChangeSelected">
                <controls:ChangesetParticiationControl.Changes>
                    <Binding Path="Changes"/>
                </controls:ChangesetParticiationControl.Changes>
            </controls:ChangesetParticiationControl>
        </DataTemplate>
        <!--<Style x:Key="ParticipationEntryStyle" TargetType="{controls:ChangesetControl}">
            <EventSetter Event="ChangeSelected" Handler="HandleChangeSelected"/>
        </Style>-->
        <DataTemplate x:Key="ResetEntry" DataType="Profile">
            <Button Width="8" Height="20" Click="ResetButton_Click"/>
        </DataTemplate>

        <DataTemplate x:Key="ResetHeader" DataType="Profile">
            <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <TextBlock FontSize="10">
                    <TextBlock.Text>
                        <Binding/>
                    </TextBlock.Text>
                    <TextBlock.LayoutTransform>
                        <RotateTransform 
                            Angle="-90"
                            CenterX="0"
                            CenterY="0" />
                    </TextBlock.LayoutTransform>
                </TextBlock>
            </Canvas>
        </DataTemplate>
        
        <Style x:Key="ResetHeaderStyle" TargetType="{x:Type GridViewColumnHeader}" >
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <RotateTransform 
                        Angle="-90"
                        CenterX="10"
                        CenterY="10" />
                </Setter.Value>
            </Setter>
        </Style>

    </Control.Resources>

    <ListView Name="_listView" DockPanel.Dock="Top" VerticalAlignment="Stretch" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True">
        <ListView.View>
            <GridView x:Name="_gridView">
                <GridViewColumn Header="Asset Location" Width="400" CellTemplate="{StaticResource AssetLocation}"/>
                <!--<GridViewColumn HeaderContainerStyle="{StaticResource ResetHeaderStyle}" Header="Reset" Width="20" CellTemplate="{StaticResource ResetEntry}"/>-->
                <GridViewColumn HeaderTemplate="{StaticResource ResetHeader}" Header="Reset" Width="20" CellTemplate="{StaticResource ResetEntry}"/>
                <GridViewColumn Header="Previous" Width="80" CellTemplate="{StaticResource PreviousChangesetEntry}"/>
                <GridViewColumn Header="Last" Width="80" CellTemplate="{StaticResource LastChangesetEntry}"/>
                <GridViewColumn Header="Participation in Changesets" CellTemplate="{StaticResource ParticipationEntry}"/>
            </GridView>
        </ListView.View>
    </ListView>
</UserControl>
